<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__ROOT__/Apps/Admin/View/css/AdminLTE.css" rel="stylesheet" type="text/css" />
      <link href="__ROOT__/Apps/Admin/View/css/upload.css" rel="stylesheet" type="text/css" />
      <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/webuploader/webuploader.css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <script type="text/javascript" src="__ROOT__/Apps/Admin/View/js/upload.js"></script>
	  <script type="text/javascript" src="__PUBLIC__/plugins/webuploader/webuploader.js"></script>
      <script src="__PUBLIC__/plugins/layer/layer.min.js"></script>
      
   <script>
   var ThinkPHP = window.Think = {
	        "ROOT"   : "__ROOT__",
	        "PUBLIC" : "__PUBLIC__",
	        "DOMAIN" : "{:WSTDomain()}"
	};
   function getAreaList(parentId){
	   var params = {};
	   params.parentId = parentId;
	   var id = $('#defaultCity_hidden').val();
	   $('#defaultCity').empty();
	   var html = [];
	   $.post("{:U('Admin/Areas/queryByList')}",params,function(data,textStatus){
		    html.push('<option value="">请选择</option>');
			var json = WST.toJson(data);
			if(json.status=='1' && json.list.length>0){
				var opts = null;
				for(var i=0;i<json.list.length;i++){
					opts = json.list[i];
					html.push('<option value="'+opts.areaId+'" '+((id==opts.areaId)?'selected':'')+'>'+opts.areaName+'</option>');
				}
			}
			$('#defaultCity').html(html.join(''));
	   });
   }

      $(function(){
    	  $('#myTab a').click(function (e) {
    		  e.preventDefault();
    		  $(this).tab('show');
    	  });
    	  <PHP>if($areaId1!=0){</PHP>
     	   getAreaList('{$areaId1}');
     	  <PHP>}</PHP>  
    	  <PHP>if($CONF['mallLicense']==''){</PHP>
    	  //$('#mallCopyright').attr('disabled',true);
    	  <PHP>}</PHP>
    	  <php>
  		  foreach($configs as $key =>$cf){
  		  foreach($cf as $key =>$vo){
  			if($vo['fieldType']=='upload'){
  		  </php>
    	  <php>}}}</php>
    	  
    	var uploading = null;
  		uploadFile({
  	    	  server:"{:U('Admin/Index/uploadPic')}",
  	    	  pick:'#filePicker',
  	    	  formData: {dir:'mall'},
  	    	  callback:function(f){
  	    		  layer.close(uploading);
  	    		  var json = WST.toJson(f);
  	    		  $('#preview').attr('src',ThinkPHP.DOMAIN+"/"+json.file.savepath+json.file.savethumbname);
  	    		  $('#friendlinkIco').val(json.file.savepath+json.file.savename);
  	    		  $('#preview').show();
  		      },
  		      progress:function(rate){
  		  		 uploading = WST.msg('正在上传图片，请稍后...');
  		      }
  	    });
  		
      })
      function save(){
    		var params = {};
    		<php>
    		foreach($configs as $key =>$cf){
    		foreach($cf as $key =>$vo){
    			if($vo['fieldType']=='radio'){
    	    </php>
    			params.{$vo['fieldCode']} = $("input:radio[name='{$vo['fieldCode']}']:checked").val();
    		<php>}else{</php>
    			params.{$vo['fieldCode']} = $.trim($('#{$vo['fieldCode']}').val());
    		<php>}}}</php>
    		if(params.defaultCity==''){
    			Plugins.Tips({title:'信息提示',icon:'error',content:'请选择商城的默认城市!',timeout:1000});
    			return;
    		}
    		Plugins.waitTips({title:'信息提示',content:'正在提交数据，请稍后...'});
    		$.post("{:U('Admin/index/saveMallConfig')}",params,function(data,textStatus){
    			var json = WST.toJson(data);
    			if(json.status=='1'){
    				Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){}});
    			}else{
    				Plugins.closeWindow();
    				Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
    			}
    		});
    	}
      </script>
   </head>
   <body>
      <ul id="myTab" class="nav nav-tabs wst-tab" role="tablist">
	      <li class="active"><a href="#tabc0" role="tab" data-toggle="tab">商城设置</a></li>
	      <li><a href="#tabc1" role="tab" data-toggle="tab">邮件设置</a></li>
	      <li><a href="#tabc2" role="tab" data-toggle="tab">短信设置</a></li>
	      <li><a href="#tabc3" role="tab" data-toggle="tab">运营设置</a></li>
	      <li><a href="#tabc4" role="tab" data-toggle="tab">登录设置</a></li>
	      <li><a href="#tabc5" role="tab" data-toggle="tab">微信公众号设置</a></li>
	      <li><a href="#tabc6" role="tab" data-toggle="tab">分销设置</a></li>
	  </ul>
      <div class='tab-content wst-tab-content'>
      	  <iframe name="upload" style="display:none"></iframe>
          <foreach name="configs"  item="vo" key="k">
          <div class='tab-pane <if condition="$k eq 0">active in</if> fade wst-tab-pane' id='tabc{$k}'>
          <if condition="$k==0">
          	
			
          </if>
            
               <table class='table table-hover table-striped table-bordered wst-form'>
               <foreach name="vo"  item="v" key="key">
               <tr>
                  <th width='150'>{$v['fieldName']}：</th>
                  <td>
                     <php>
                     if($v['fieldType']=='text'){
                     </php>
                     <input type='text' autocomplete="off" class="form-control wst-ipt" id='{$v["fieldCode"]}' name='{$v["code"]}' value="{$v['fieldValue']}" /><span style="color:red;">{$v['fieldTips']}</span>
                     <php>
                     }else if($v['fieldType']=='radio'){
                        foreach($v['txt'] as $kt => $vt){
                     </php>
                       <label>
			           <input type='radio' id='{$v["val"][$kt]}_{$kt}' autocomplete="off" name='{$v["fieldCode"]}' value='{$v["val"][$kt]}' size='30' <php>if($v["fieldValue"]==$v["val"][$kt]){ echo "checked";}</php> />{$vt}&nbsp;&nbsp;
			           </label>
			         <php>
			            }
			         </php><span style="color:red;">{$v['fieldTips']}</span>
                     <php>}else if($v['fieldType']=='textarea'){</php>
                     <textarea id='{$v["fieldCode"]}' autocomplete="off" name='{$vo["fieldCode"]}' style='width:400px;height:100px;'>{$v['fieldValue']}</textarea><span style="color:red;">{$v['fieldTips']}</span>
                     <php>}else if($v['fieldType']=='other'){</php>
                     <php>if($v['fieldCode']=='defaultCity'){</php>
                     <select name='areaId1' id='areaId1' onchange='javascript:getAreaList(this.value)'>
			             <option value=''>请选择</option>
			             <volist name="areaList" id="vo">
			             <option value='{$vo['areaId']}' <if condition="$areaId1 == $vo['areaId'] ">selected</if>>{$vo['areaName']}</option>
			             </volist>
			         </select>
			         <select name='defaultCity' id='defaultCity'>
			             <option value=''>请选择</option>
			          </select>
			          <input id='defaultCity_hidden' type='hidden' value='{$v['fieldValue']}'/>
                     <php>}</php>
                     <php>}else if($v['fieldType']=='upload'){</php>
                     	
                     	<script type="text/javascript">
                     	$(function(){
					    	var uploading = null;
					    	
					  		uploadFile({
					  	    	  server:"{:U('Admin/Index/uploadPic')}",
					  	    	  pick:'#{$v["fieldCode"]}_picker',
					  	    	  formData: {dir:'mall'},
					  	    	  callback:function(f){
					  	    		  layer.close(uploading);
					  	    		  var json = WST.toJson(f);
					  	    		  
					  	    		  $('#{$v["fieldCode"]}_view').attr('src',ThinkPHP.DOMAIN+"/"+json.file.savepath+json.file.savethumbname);
					  	    		  
					  	    		  $('#{$v["fieldCode"]}').val(json.file.savepath+json.file.savename);
					  	    		  $('#{$v["fieldCode"]}_view').show();
					  		      },
					  		      progress:function(rate){
					  		  		 uploading = WST.msg('正在上传图片，请稍后...');
					  		      }
					  	    });
					  		
					      })
                     	</script>
                       	
						<div style="position:relative;">
							<input id="{$v['fieldCode']}"  name="{$v['fieldCode']}" class="form-control wst-ipt" type="hidden" value="{$v['fieldValue']}" />
							<div>
								<div id="{$v['fieldCode']}_picker" >上传图片</div>
							</div>
							<div style="clear:both;"></div>
							<div style="color:red;">{$v['fieldTips']}</div>
						</div>
                     	<div id="preview_{$v['fieldCode']}">
                     		<img id='{$v["fieldCode"]}_view' src='__ROOT__/{$v['fieldValue']}' width="152" height="152"/>
                     	</div>
                     <php>}</php>
                  </td>
               </tr>
               </foreach>
               <tr>
                 <td style='padding-left:250px;' colspan='2'>
                    <button type="button" class="btn btn-primary" onclick='javascript:save()'>保&nbsp;存</button>
                    <button type="reset" class="btn btn-primary">重&nbsp;置</button>
                 </td>
               </tr>
               </table>
            
          </div>
          </foreach>
      </div>
   </body>
</html> 